package com.example.javaee_library.dao;

import com.example.javaee_library.Entity.Book;
import com.example.javaee_library.Entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Miao-yongzheng
 * @create 2021-12-14 21:18
 */
@Mapper
public interface UserDao {
    /*/**
    * @Description: 登录查询用户
    * @Param: [Id]
    * @return: [Id]
    * @Author: Miao
    * @Date: 2021/12/21
    */
@Select("select * from user where Id = #{Id} and password = #{password}")
    User login(int Id,String password);
/*/**
* @Description: 删除用户
* @Param: [Id]
* @return: [Id]
* @Author: Miao
* @Date: 2021/12/21
*/
@Delete("DELETE FROM user  WHERE Id = #{Id}")
    int Delete(int Id);
/*/**
* @Description: 查询所有用户
* @Param: []
* @return: []
* @Author: Miao
* @Date: 2021/12/21
*/
@Select("select * from user")
    List<User> selectAll();
/*/**
* @Description: 修改用户全部信息
* @Param:
* @return:
* @Author: Miao
* @Date: 2021/12/21
*/
@Update("update user set  Id = #{oldId}, password=#{password}\n" +
        "where Id = #{oldId};")
    int UpdatebyUser(int oldId,String password);

/*/**
* @Description: 模糊查询用户
* @Param:
* @return:
* @Author: Miao
* @Date: 2021/12/22
*/
@Select("SELECT * from user\n" +
        "where id like #{UserId}")
List<User> Serach(String UserId);

/*/**
* @Description: 插入用户
* @Param:
* @return:
* @Author: Miao
* @Date: 2021/12/22
*/
    @Insert("insert into user values (#{UserId},#{password},#{autority})")
    int Insert(int UserId,String password,String autority);

    /*/**
     * @Description: 精准查询用户
     * @Param:
     * @return:
     * @Author: Miao
     * @Date: 2021/12/22
     */
    @Select("SELECT * from user\n" +
            "where id = #{UserId}")
    User Serach_Byuserid(String UserId);
    /*/**
    * @Description: 管理员修改
    * @Param:
    * @return:
    * @Author: Miao
    * @Date: 2022/1/4
    */
    @Update("update user set Id = #{oldId},password = #{password},\n" +
            "                authority = #{authority},\n" +
            "                state = #{state},\n" +
            "                deleted = #{deleted}\n" +
            "where Id = #{oldId};")
    int UpdatebyAdmin(int oldId,String password,String authority,int state,int deleted);

    /*/**
    * @Description: 冻结状态sql
    * @Param:
    * @return:
    * @Author: Miao
    * @Date: 2022/1/4
    */
    @Update("update user set state = #{state} where Id = #{Id}")
    int Changefreeze(int Id,int state);
}
